<!DOCTYPE HTML>
<html>
<head>

    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    <title>创建/编辑菜单</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link rel="stylesheet" href="/static/admin/css/style.css" />
    <link rel="stylesheet" href="/static/admin/css/editormd.css" />
    <style type="text/css">
table.admin_table {
    font-family: verdana,arial,sans-serif;
    font-size:11px;
    color:#333333;
    border-width: 1px;
    border-color: #999999;
    border-collapse: collapse;
    width: 98%;
    margin: 10px 10px;
}
table.admin_table th {
    background-color:#DCDCDC;
    border-width: 1px;
    padding: 8px;
    border-style: solid;
    border-color: #999999;
}
table.admin_table td {
    background-color:#F5F5F5 ;
    border-width: 1px;
    padding: 8px;
    border-style: solid;
    border-color: #999999;
}

        .center{
            margin: auto auto;
        }
        h1{
            font-family: "Ariel";
            font-weight: normal;
        }

        .btn {
            display: inline-block;
            *display: inline;
            padding: 4px 12px;
            margin-bottom: 0;
            *margin-left: .3em;
            font-size: 14px;
            line-height: 20px;
            color: #333333;
            text-align: center;
            text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
            vertical-align: middle;
            cursor: pointer;
            background-color: #f5f5f5;
            *background-color: #e6e6e6;
            background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6);
            background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6));
            background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6);
            background-image: -o-linear-gradient(top, #ffffff, #e6e6e6);
            background-image: linear-gradient(to bottom, #ffffff, #e6e6e6);
            background-repeat: repeat-x;
            border: 1px solid #cccccc;
            *border: 0;
            border-color: #e6e6e6 #e6e6e6 #bfbfbf;
            border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
            border-bottom-color: #b3b3b3;
            -webkit-border-radius: 4px;
            -moz-border-radius: 4px;
            border-radius: 4px;
            filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0);
            filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
            *zoom: 1;
            -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
            -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
        }

        .btn:hover,
        .btn:focus,
        .btn:active,
        .btn.active,
        .btn.disabled,
        .btn[disabled] {
            color: #333333;
            background-color: #e6e6e6;
            *background-color: #d9d9d9;
        }

        .btn:active,
        .btn.active {
            background-color: #cccccc \9;
        }

        .btn:first-child {
            *margin-left: 0;
        }

        .btn:hover,
        .btn:focus {
            color: #333333;
            text-decoration: none;
            background-position: 0 -15px;
            -webkit-transition: background-position 0.1s linear;
            -moz-transition: background-position 0.1s linear;
            -o-transition: background-position 0.1s linear;
            transition: background-position 0.1s linear;
        }

        .btn:focus {
            outline: thin dotted #333;
            outline: 5px auto -webkit-focus-ring-color;
            outline-offset: -2px;
        }

        .btn.active,
        .btn:active {
            background-image: none;
            outline: 0;
            -webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
            -moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
            box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
        }

        .btn.disabled,
        .btn[disabled] {
            cursor: default;
            background-image: none;
            opacity: 0.65;
            filter: alpha(opacity=65);
            -webkit-box-shadow: none;
            -moz-box-shadow: none;
            box-shadow: none;
        }


        .input_text {
            display: inline-block;
            *display: inline;
            padding: 4px 12px;
            margin-bottom: 0;
            *margin-left: .3em;
            font-size: 14px;
            line-height: 20px;
            color: #000;
            text-align: left;
            text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
            vertical-align: middle;
            cursor: pointer;
            background-color: #ffffff;
            *background-color: #ffffff;
            background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6);
            background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6));
            background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6);
            background-image: -o-linear-gradient(top, #ffffff, #e6e6e6);
            background-image: linear-gradient(to bottom, #ffffff, #e6e6e6);
            background-repeat: repeat-x;
            border: 1px solid #cccccc;
            *border: 0;
            border-color: #e6e6e6 #e6e6e6 #bfbfbf;
            border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
            border-bottom-color: #b3b3b3;
            -webkit-border-radius: 4px;
            -moz-border-radius: 4px;
            border-radius: 4px;
            filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0);
            filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
            *zoom: 1;
            -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
            -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
            box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
        }
    </style>
</head>
<body>
<?php include APP_ADMIN_VIEW . 'include/head.php';?>
<form id='menu_form' action='/<?php echo APP_ADMIN_URI; ?>/menu/create' method="POST">

<table class="admin_table">
<tr>
<td>
    <span>上级菜单：</span>
    <select id="parent_id" name="parent_id" calss='btn' style="width:200px">
        <option value="0" selected="selected">顶级菜单</option>
    </select>
</td>
<td>
    <span>发布状态：</span>
    <select name="status" calss='btn'>
        <option value="1" <?php if (isset($menu_data['status']) && $menu_data['status'] == 1): ?>selected="selected"<?php endif?>>发布</option>
        <option value="0" <?php if (isset($menu_data['status']) && $menu_data['status'] == 0): ?>selected="selected"<?php endif?>>未发布</option>
    </select>
</td>
</tr>
<tr>
<td colspan="2"  align="left">
            <label>
                名称：
<input type="text" class="input_text" style="width: 600px;"name="menu_name" value="<?php echo isset($menu_data['menu_name']) ? $menu_data['menu_name'] : ''; ?>"/>
</label>
</td>
</tr>
<tr>
<td colspan="2"  align="left">
<label>
                别名：
<input type="text" class="input_text" style="width: 600px;"name="menu_url" value="<?php echo isset($menu_data['menu_url']) ? $menu_data['menu_url'] : ''; ?>"/>
</label>
</td>
</tr>
<tr>
    <td align="left">
       <label>

    关键词：
    <input type="text"  name="keywords" class="input_text"  value="<?php echo isset($menu_data['keywords']) ? $menu_data['keywords'] : ''; ?>"/>
    </label>
    </td>
    <td  align="left">

    <label>
        简介：<textarea rows="2" cols="60" class="input_text"  name="description"><?php echo isset($menu_data['description']) ? $menu_data['description'] : ''; ?></textarea>
    </label>
    </td>
</tr>
<tr>
    <td colspan="2" align="center">
         <input type="hidden" name="hash" value='<?php echo isset($menu_data['hash']) ? $menu_data['hash'] : ''; ?>'/>
         <button class="btn" onclick="savePost()">保存</button>&nbsp;&nbsp;
         <a href="/<?php echo APP_ADMIN_URI; ?>/menu/list" class="btn" style="" >返回列表</a>
    </td>
</tr>
</table>
</form>
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">

    function savePost() {
        var md=contentMdEditor.getMarkdown();
       $('#content').text(md);
       document.getElementById('menu_form').submit();
    }

 $(function() {// 初始化内容
    //加载菜单数据
 $.ajax({
            url:"/admin/menu/json",
            data:{},
            type:"POST",
            dataType:"json",
            timeout:5000,
            success:function(json){
                $.each(json, function (n, value) {
                    current_id=<?php echo isset($menu_data['parent_id']) ? intval($menu_data['parent_id']) : 0; ?>;
                    selected_str="";
                    if(current_id==value.id){
                        selected_str=" selected='selected' ";
                    }
                    options_str="<option value='"+value.id+"'"+selected_str+">"+value.menu_name+"</option>";

                    $("#parent_id").append(options_str);
                });

            },
            error:function(xhr, status){
                alert("请求出错。");
            }
    });
});
</script>
<?php include APP_ADMIN_VIEW . 'include/foot.php';?>
</body>
</html>